<template>
  <div class="EmergencyDetail">
    <div class="flex location-wrap">
      <span class="white">当前位置：</span>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/EWManagement' }">预警管理</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/InformationList' }">预警信息</el-breadcrumb-item>
        <el-breadcrumb-item>详情</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="EmergencyDetail-center">
      <TimeLine :activities="activities" :title="'预警事件流程'" />
      <div class="EmergencyDetail-add">
        <div class="EmergencyDetail-titel">
          <div class="EmergencyDetail-top">预警信息记录</div>
          <div class="flexBetween">
            <div slot="title" class="flex">
              <!-- <div class="leftLine"></div> -->
              <div class="fontSize16"></div>
            </div>
            <el-row>
              <el-button size="mini" @click="AddFh">返回</el-button>
            </el-row>
          </div>
        </div>
        <div class="EmergencyDetail-zt">
          <el-collapse v-model="activeNames">
            <el-collapse-item name="1">
              <div slot="title" class="title_box">
                <div class="flex">
                  <div class="leftLine"></div>
                  <div class="fontSize16">信息来源</div>
                </div>
                <div style="display:flex;align-items: center;">
                  <i :class="judgeActive('1') !== -1 ? 'downArrow1' : 'downArrow2'" />
                </div>
              </div>
              <div class=" information_Sources_content">
                <div class="task_distribution">
                  <div>信息来源：{{ DetailList.infoSourceName }}</div>
                </div>
              </div>
            </el-collapse-item>
            <el-collapse-item name="2">
              <div slot="title" class="title_box">
                <div class="flex">
                  <div class="leftLine"></div>
                  <div class="fontSize16">基本信息</div>
                </div>
                <div style="display:flex;align-items: center;">
                  <i :class="judgeActive('2') !== -1 ? 'downArrow1' : 'downArrow2'" />
                </div>
              </div>
              <div class="information_Sources_content">
                <div class="information_Sources_content">
                  <div class="task_distribution marginB15">
                    <div>预警信息：{{ DetailList.warningInfo }}</div>
                  </div>
                </div>
                <div class="information_Sources_content">
                  <div class="task_distribution information nametites">
                    <div>险情类别：{{ DetailList.dangerName }}</div>
                    <div>&nbsp;&nbsp;&nbsp;预警级别：{{ DetailList.warningLvName }}</div>
                    <!-- <div></div> -->
                    <!-- <div class="">影响范围：{{rangeDetailVos}}</div> -->
                    <div>影响时间：{{ DetailList.effectStartTime }}至{{ DetailList.effectEndTime }}</div>
                  </div>
                </div>
                <div class="information_Sources_content stylecv">
                  <div class="task_distribution  nametites">
                    <div class="nametite">影响范围：</div>
                    <div class="nametit">{{ rangeDetailVos }}</div>
                  </div>
                </div>
                <div class="information_Sources_content stylecv">
                  <div class="task_distribution  nametites">
                    <div class="nametite">事件概要：</div>
                    <div class="nametit">{{ DetailList.incidentOutline }}</div>
                  </div>
                </div>
                <div class="information_Sources_content stylecv">
                  <div class="task_distribution marginB15">
                    <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;附件：<router-link to="" class=""
                        v-for="(item, index) in attachInfo" :key="index"><span style="color: #3561fd;
          text-decoration: underline;" @click="handlePreview(item)">{{
            item.attachName }},</span></router-link>
                    </div>
                  </div>
                </div>
              </div>
            </el-collapse-item>
            <el-collapse-item name="3">
              <div slot="title" class="title_box">
                <div class="flex">
                  <div class="leftLine"></div>
                  <div class="fontSize16">填报信息</div>
                </div>
                <div style="display:flex;align-items: center;">
                  <i :class="judgeActive('3') !== -1 ? 'downArrow1' : 'downArrow2'" />
                </div>
              </div>
              <div class="information_Sources_content">
                <div class="task_distribution information">
                  <div>&nbsp;&nbsp;&nbsp;填报人：{{ DetailList.creator }}</div>
                  <!-- <div>单位及部门：{{DetailList.unitDeptName}}</div> -->
                  <div class="danweijibumen_box">
                    <span class="name">单位及部门：</span><span class="danweijibumen">{{ DetailList.unitDeptName }}</span>
                  </div>
                  <div>填报时间：{{ DetailList.createTime }}</div>
                </div>
              </div>
            </el-collapse-item>
          </el-collapse>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getById } from "../../../api/EarlyWarningManagement/yjxxsj";
import { loadFile } from "@/api/common.js";
import TimeLine from "@/components/component/timeLine.vue";
export default {
  name: "EmergencyDetail",
  components: { TimeLine },
  data() {
    return {
      activeNames: ["1", "2", "3"],
      activities: [],
      DetailList: {},
      attachInfo: [],
      rangeDetailVos: ""
    };
  },
  mounted() {
    this.detailList();
    // this.getFlowList()
  },
  methods: {
    async detailList() {
      const res = await getById(
        { id: this.$route.query.id });
      this.DetailList = res;
      this.activities = res.warningFlowListVos;
      this.attachInfo = res.attachInfo;
      this.rangeDetailVos = res.rangeDetailVos.map(item => {
        return item.effectRange;
      });
      this.rangeDetailVos = this.rangeDetailVos.join("、");
    },
    // 下载
    handlePreview(item) {
      // this.$message({
      //   message: "功能开发中",
      //   type: "success"
      // });
      const loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.6)"
      });
      loadFile({ id: item.attachId }).then(res => {
        const a = document.createElement("a");
        const objectUrl = URL.createObjectURL(res);
        a.setAttribute("href", objectUrl);
        a.setAttribute("download", item.name);
        a.click();
        loading.close();
      }).catch(() => {
        loading.close();
      });
    },
    judgeActive(data) {
      return this.activeNames.indexOf(data);
    },
    // 返回上一级
    AddFh() {
      // this.$router.push({
      //   name: "InformationList"
      // });
      if (this.$route.query.type) {
        this.$router.go(-2);
      } else {
        this.$router.go(-1);
      }
    }
  }
};
</script>

<style scoped lang="less">
.stylecv {
  padding: 8px 0;
}

.danweijibumen_box {
  display: flex;
  align-items: center;



  .name {
    display: flex;
    justify-content: center;
    align-items: center;
    place-self: baseline;
  }

  .danweijibumen {
    display: inline-block;
    width: 320px;
    height: 100px;
  }
}

.EmergencyDetail {
  width: 100%;
  height: 100%;

  :deep(.el-timeline) {
    width: 85%;
    margin-left: 35px;
    margin-top: 30px;
  }

  .nametite {
    width: 80px;
  }

  .nametit {
    flex: 1;
  }

  .nametites {
    display: flex;
  }

  :deep(.el-collapse-item__arrow) {
    display: none;
  }

  :deep(.el-collapse-item__header) {
    justify-content: space-between;
  }

  .downArrow1 {
    display: inline-block;
    width: 10px;
    height: 10px;
    background-image: url("../../../assets/img/downArrow1.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
  }

  .downArrow2 {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: url("../../../assets/img/downArrow1.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    transform: rotate(-180deg);
  }

  :deep(.el-breadcrumb__inner.is-link) {
    font-weight: 100;
    color: #fff;
  }

  :deep(.el-breadcrumb__item:last-child .el-breadcrumb__inner) {
    color: #3270ff;
  }

  :deep(.el-breadcrumb) {
    font-size: 16px;
    line-height: initial;
  }

  .EmergencyDetail-center {
    width: 100%;
    height: 100%;
    margin-top: 10px;
    display: flex;
    justify-content: space-between;

    .EmergencyDetail-add {
      width: 83%;
      height: 100%;
      background-color: #fff;
      border-radius: 5px;
      overflow: auto;

      .EmergencyDetail-titel {
        margin: 0 20px;
        position: relative;
        padding: 10px 0 5px 0;

        // border-bottom: solid 1px #ccc;
        .EmergencyDetail-top {
          text-align: center;
          font-family: 微软雅黑;
          font-weight: 400;
          font-style: normal;
          font-size: 28px !important;
        }
      }

      .EmergencyDetail-zt {
        overflow-y: auto;
        margin: 0 20px;

        :deep(.el-button--text) {
          color: #606266;
          padding: 2px;
        }

        .EmergencyList-dialog-form-item {
          display: flex;
          justify-content: space-between;
          flex-wrap: wrap;
        }

        .task_distribution {
          display: flex;
          // align-items: center;
          padding: 0 30px;
          font-size: 16px;

          // span {
          //   color: #3561fd;
          //   text-decoration: underline;
          // }
        }

        .task_distribution.information {
          flex-wrap: wrap;

          div {
            width: 30%;
            margin-bottom: 12px;
            align-items: center;

            img {
              position: relative;
              top: 5px;
              left: 10px;
            }
          }
        }
      }
    }
  }
}

:deep(.el-step__icon.is-text) {
  border: none;
}

:deep(.el-collapse-item__content) {
  padding-top: 5px;
  padding-bottom: 10px;
  font-size: 16px;
}

.yuandian1 {
  display: inline-block;
  background-color: #ccc;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.ydBgcolor {
  background-color: #246dfd;
  box-shadow: 0px 0px 8px 0px rgb(10, 99, 241);
}

.EmergencyList-table-pag {
  float: right;
  margin-top: 10px;

  >div {
    line-height: 32px;
  }
}

:deep(.el-table) {
  font-size: 16px;

  tr {
    > :last-child {
      padding: 0;

      img {
        display: block;
        margin: auto;
      }
    }
  }

  .white-row {
    background: #f0f2f5;
  }
}

:deep(.el-collapse-item__header) {
  border-bottom: 1px solid #ccc;
}

:deep(.el-collapse-item__content) {
  padding: 15px 0;
}

:deep(.el-collapse-item__wrap) {
  border: none;
}

.title_box {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid-content {
  background-color: #b1c8f9;
  border: 1px solid #d7d7d7;
  text-align: center;
  padding: 8px 0;
}

.grid-content.bottom_col {
  background-color: #f0f2f5;
  border: 1px solid #d7d7d7;
}

.grid-content.top_col {
  background-color: #fff;
  border-top: none;
  border-bottom: none;
}
</style>



